import socket
#TCP连接
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect(('localhost', 12345))
    data = s.recv(1024)
    print('Received:', data.decode())
#UDP连接

with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
    s.sendto(b'Hello, server!', ('localhost', 12345))
    data, addr = s.recvfrom(1024)
    print('Received from server:', data.decode())
